<?php
use yii\helpers\Url;
/* @var $this \yii\web\View */
/* @var $content string */
/* @var \common\models\UserCase $info */

$this->title = '个人病史'
?>
<section class="app-container app-form app-send">
    
    <!-- form -->
    <div class="app-form-group">
        <label for="">临床诊断：</label>
        <input type="text" class="app-form-control" placeholder="临床诊断" name="diagnosis" value="<?= $info->diagnosis ?>">
    </div>
    <div class="app-form-group">
        <label for="">患病时间：</label>
        <input type="text" class="app-form-control" placeholder="患病时间" name="sick_time" value="<?= $info->sick_time?>">
    </div>
    <div class="app-form-group">
        <label for="">既往病史：</label>
        <input type="text" class="app-form-control" placeholder="既往病史" name="medical_history" value="<?= $info->medical_history ?>">
    </div>
    <div class="app-form-group">
        <label for="">过敏史：</label>
        <input type="text" class="app-form-control" placeholder="过敏史" name="irritability_history" value="<?= $info->irritability_history ?>" >
    </div>
    <div class="app-form-group">
        <label for="">家族病史：</label>
        <input type="text" class="app-form-control" placeholder="家族病史" name="family_history" value="<?= $info->family_history ?>" >
    </div>
    <div class="app-form-group">
        <label for="">个人嗜好：</label>
        <input type="text" class="app-form-control" placeholder="个人嗜好" name="hobby" value="<?= $info->hobby ?>" >
    </div>

    <div class="app-form-group">
        <label for="">居住地址：</label>
        <input type="text" class="app-form-control" name="address" placeholder="居住地址" value="<?= $info->address ?>">
    </div>
    <div class="app-form-button">
        <input type="hidden" name="_csrf-frontend" value="<?= Yii::$app->request->csrfToken ?>">
        <button class="app-form-control app-btn-submit" id="submit">保存</button>
    </div>
    
</section>
<script src="/js/jquery.min.js"></script>
<script src="/js/layer_mobile/layer.js"></script>
<script>
    $(function(){
        var _csrf = '<?= Yii::$app->request->csrfToken ?>';
        var submitUrl = '<?= Url::toRoute(['member/case']) ?>'
        $('#submit').click(function(){
            var diagnosis = $('input[name="diagnosis"]').val();
            var sick_time = $('input[name="sick_time"]').val();
            var medical_history = $("input[name='medical_history']").val();
            var irritability_history = $("input[name='irritability_history']").val();
            var family_history = $("input[name='family_history']").val();
            var hobby = $("input[name='hobby']").val();
            var address = $("input[name='address']").val();
            var request = {
                diagnosis: diagnosis,sick_time:sick_time,medical_history:medical_history,irritability_history:irritability_history,family_history:family_history,hobby:hobby,address:address,"_csrf-frontend":_csrf
            }
            layer.open({type: 2, shadeClose: false});
            $.post(submitUrl, request, function(result){
                layer.closeAll();
                if( result.success == true ){
                    layer.open({
                        shadeClose: false,
                        content: '保存成功',
                        btn: '确定',
                        end: function(){
                            window.history.back();
                        }
                    });
                }else{
                    layer.open({
                        shadeClose: false,
                        content: result.msg,
                        btn: '确定',
                    });
                }
            }, 'json')
            
        })
    });
</script>
